package br.com.californiahotel.client.architecture.viewController;

import br.com.californiahotel.client.CaliforniaHotel;
import br.com.californiahotel.client.CaliforniaHotel.History;

import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.toolbar.ToolStripButton;

public abstract class MaintenanceController extends BasicController {

	public interface MaintenanceDisplay extends DisplayController {
		ToolStripButton getNewButton();
		ToolStripButton getEditButton();
		ToolStripButton getDeleteButton();
		ListGrid getGrid();
	}

	public MaintenanceController(MaintenanceDisplay display) {
		super(display);
		setGridContent();
	}

	protected abstract void setGridContent();

	@Override
	protected abstract void bind();

	protected MaintenanceDisplay getMaintenanceDisplay() {
		return ((MaintenanceDisplay)getDisplayController());
	}

	protected ClickHandler newButtonClickEvent(final History button) {
		return new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {
				CaliforniaHotel.changeHistory(button);
			}
		};
	}
}
